Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

251
Views
Module Build Failed: Duplicate Declaration "Editor"

I am trying to implement "RichEditor" example provided by Facebook in my project Here is the code:

import React from 'react;
import { Component } from 'react';
import { Editor, EditorState, RichUtils } from 'draft-js';
import { Map } from 'immutable';

'use strict';

const { Editor, EditorState, RichUtils } = Draft;

//rest of the code...

Whenever I tried to build using webpack-dev-server, I am getting the following error. I checked StackOverflow to see if some other user has encountered an exact error. But, couldn't find one.

Module Build Failed: Duplicate Declaration "Editor"

'use strict';
> const { Editor, EditorState, RichUtils } = Draft;

export class ...{}

Where am I going wrong?

Note: I am new to ReactJS.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

You're importing Editor up top, and then you are also defining it again when you are destructuring Draft.

You either need to alias Editor in the import of draft-js like this:

import { Editor as DEditor, EditorState, RichUtils } from 'draft-js';

From here you would use Deditor instead of Editor. Then you would be free to name the const Editor below...

Or, just don't destructure the Draft object below.

Instead of const { Editor, EditorState, RichUtils } = Draft;, access the property of Draft with dot syntax. i.e. Draft.Editor, Draft.EditorState, etc...

over 4 years ago · Santiago Trujillo Report

0

Also this duplicate declaration error happens if you are importing a predefined default import with the same name as a component somewhere else in your imports.

Example:

import bla from 'react-bla';
://more imports
://more imports
import bla from '../Components/bla/bla';
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!